﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<ToppingControl.Models.TopCordPlanModel.TopCordPlan_DS>>" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
   <form id="myform" action="">
   <div><h2 style="color:#191970">TOPPED CORD PLAN</h2></div>
    <div class="cap shadow txt13bold">
         TOPPING NO :
      </div>
      <div id="code" class="desc txt13bold" style="width: 200px;">1</div>
      
          <div class="cap shadow txt13bold">
         PLAN DATE :
      </div>
      <div id="Txtpladt" class="desc txt13bold" style="width: 200px;">
          <input type="text" id="dFrom" value="<%=  ViewBag.Message  %>"  />
         
      </div><button  id="search"></button>
       <div style="clear:left" />

   <div>
   <ul id="menu1" class="menu1" style="vertical-align:bottom;">
  
      <li class="aa" id="unlock"><a href="#">UNLock</a></li>
      <li class="aa" id="lock"><a href="#">All Lock</a></li>      
      <li id="edit" style="padding-left:75%"><a href="#">Edit</a></li>

   <%--   <li class="above"><a href="#">Insert line above</a></li>
      <li class="under"><a href="#">Under line</a></li>--%>
       
   </ul>
   </div>
   <table width="100%" class=" shadow "  id="dataTbl">
  <thead>
         <tr class="head"  id="trRow">
            <td class="cell "  style="width: 50px;">
               STATUS               
            </td>
            <td class="cell" style="width: 120px;">
               SEQ
            </td>
            <td class="cell" style="width: 250px;">
               TOPPED CORD
            </td>
            <td class="cell" style="width: 150px;">
               MANUF.
            </td>
            <td class="cell" style="width: 50px;">
               LENGTH.
            </td>  
         
         </tr>
         
      </thead>
      
   <tbody>
         <%
            int i = 0;
            
            foreach (var item in Model)
            {
               i = i + 1;
               string trrow = "rowa";
               if (i % 2 == 0) trrow = "rowb";
               string seq = item._Plandt +'-'+item._Itemno;
              
            
         %>
         <tr class='<%= trrow %>'  style="line-height:25px;">
          
            <td  style="width: 50px; text-align:center;">
               <%: Html.DisplayFor(modelItem => item._Plants) %>
            </td>
            <td style="width: 120px; text-align:center;">
               <%= seq %>
            </td>
            <td style="width: 250px; text-align:center;">
               <%: Html.DisplayFor(modelItem => item._Topcrdcd) %>
            </td>
            <td style="width: 150px;">
               <%: Html.DisplayFor(modelItem => item._Manufc) %>
            </td>
            <td style="width: 50px; text-align:center;">
               <%: Html.DisplayFor(modelItem => item._Length) %>
            </td>                       
           
           
         </tr>
         <% } %>
      </tbody>
      
   </table>
   </form>
</asp:Content>


<asp:Content ID="idTableContent" ContentPlaceHolderID="TableContent" runat="server">  
   <div style="clear:both;">
   <table class="shadow" id="UseTbl" style="text-align:left; margin-left:0px;">
  
   <thead>
         <tr class="cell" style="background-color:#ccc; color:#000; font-weight:bold;text-align:center;"><td colspan="4">USED PLAN</td></tr>
         <tr class="head"  id="trUse" style="background-color:#008080; color:White;">
            <td class="cell" style="width: 120px;">
               SEQ
            </td>
            <td class="cell" style="width: 250px;">
               TOPPED CORD
            </td>      
             <td class="cell " style="width: 150px;">MANUF.</td>
            <td class="cell" style="width: 75px;">LENGTH.(M.)</td>  
         </tr>         
   </thead>
   <tbody></tbody>
   </table>
</div>
</asp:Content>

<asp:Content ID="idJQuery" ContentPlaceHolderID="ScriptsSection" runat="server">
      <style type="text/css">
      .chk:hover
      {
         cursor: pointer;
       
      }
      .actived
      {
        color:#ff0000;      /*red*/               
      }      
    
      .txt
      {
          background-color:#f8f8e8 !important;
          border-right: #000 1px solid  !important;
      }
      .hide
      { display:none;
         }
    .skip
    {
        color:Red !important;
    }
      .samp
    {
        color:#FF6D00 !important;
    }

   </style>
   <% if (false) { %>
   <script src="../../Scripts/jquery-1.7.2.js" type="text/javascript"></script>
   <% } %>
   <script type="text/javascript">
       $(function () {
           $("#search").button({
               icons: { primary: 'ui-icon-circle-zoomout' }, text: false
           }).click(function () {

               var url = '<%=Url.Action("Index") %>' + '?dtPlan=' + $("#dFrom").val();
               window.location = url;
           }); //click

           $('#dFrom').dateEntry({ useMouseWheel: false, dateFormat: 'dmy/' })
           //Click Select Row //
           $("tr.rowa, tr.rowb ").click(function () {
               $("tr.rowa, tr.rowb").removeClass("actived");
               var $tr = $(this);

               $tr.addClass("actived");
               $tr = $tr.closest('tr').next('tr');
               while ($tr.length > 0) {
                   $tr.addClass("actived");
                   $tr = $tr.closest('tr').next('tr');
               }

           });
           //Click UNLock
           $("#unlock").click(function () {
               var getUsersUrl = '<%=Url.Action("Index") %>' + '?dtPlan=' + $("#dFrom").val();
               if ($("tr.actived:first").length <= 0) {
                   alert("กรุณาเลือกข้อมูล");
                   return false;
               }
               {
                   WAITINGDLG_show(imgWait);
                   sel = ($("tr.actived:first").find("td:eq(1)").text());
                   $.post('<%=Url.Action("unLock","ToppedCordPlan") %>' + '?sel=' + sel, function (data) {
                       alert(data.message);
                       if (data.success != "0") {
                           window.location = getUsersUrl;
                       }
                       WAITINGDLG_hide();
                   });
               }
           });
           //Click LockAll
           $("#lock").click(function () {
               WAITINGDLG_show(imgWait);
               setTimeout(function () {
                   var getUsersUrl = '<%=Url.Action("Index") %>' + '?dtPlan=' + $("#dFrom").val();

                   $.post('<%=Url.Action("LockAll") %>' + '?dtPlan=' + $("#dFrom").val(), function (data) {
                       alert(data.message);
                       if (data.success != "0") {
                           window.location = getUsersUrl;
                       }
                       WAITINGDLG_hide();
                   });
               }, 2000)

           });

           //click edit
           $("#edit").click(function () {
               var getUsersUrl = '<%= Url.Action("unLockTopping") %>' + '?dtPlan=' + $("#dFrom").val();
               window.location = getUsersUrl;
           });

           $.post('<%=Url.Action("Get_USE_ACTIVE","ToppedCordPlan") %>', function (data) {

               WAITINGDLG_show(imgWait);
               $("#UseTbl tbody").empty();

               for (i = 0; i < data.length; i++) {
                   var seq = data[i]._Plandt + '-' + data[i]._Itemno;
                   var row = "rowa";
                   if (i % 2 == 0) {
                       row = "rowa";
                   }
                   var $tr = $("#trUse").clone().addClass(row).removeAttr("style");
                   $("td:eq(0)", $tr).text(seq).addClass("text-center");
                   $("td:eq(1)", $tr).text(data[i]._Topcrdcd).addClass("text-center");
                   $("td:eq(2)", $tr).text(data[i]._Manufc).addClass("text-center");
                   $("td:eq(3)", $tr).text(data[i]._Length).addClass("text-center");
                   if (data[i]._Skpflag != "") {
                       $tr.addClass("skip");
                   }
                    if (data[i]._Sample != "") {
                       $tr.addClass("samp");
                   }

                   $tr.appendTo($("#UseTbl tbody"));
               }
               WAITINGDLG_hide();
           });



       });
   </script>
</asp:Content>

